package com.pzh.guli.service.edu.controller;


import com.pzh.guli.service.base.result.Result;
import com.pzh.guli.service.edu.pojo.vo.SubjectVo;
import com.pzh.guli.service.edu.service.ISubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author xzh
 * @since 2022-05-11
 */
@RestController
@RequestMapping("/admin/edu/subject")
public class SubjectController {
    @Autowired
    private ISubjectService subjectService;
    @PostMapping("import")
    public Result importFile(@RequestParam MultipartFile file) throws IOException {
        InputStream inputStream = file.getInputStream();
        subjectService.batchImport(inputStream);
        return Result.ok().message("上传成功");
    }
    @GetMapping("nestList")
    public Result nestList(){
        List<SubjectVo> subjectVos = subjectService.nestList();
        return Result.ok().data("item",subjectVos);
    }
}

